import { Component, OnInit, Output, EventEmitter } from '@angular/core';
import { RemoveTableService } from '../../../public/serve/remove-table/remove-table.service';
import { HintsService } from '../../../public/serve/hints/hints.service';
import {Service} from '../../../server/server';

@Component({
  selector: 'app-product-type-delete',
  templateUrl: './product-type-delete.component.html',
  styleUrls: ['./product-type-delete.component.css']
})
export class ProductTypeDeleteComponent implements OnInit {

  @Output() delete = new EventEmitter<void>();

  constructor(
      public server: Service,
    public removeTableService: RemoveTableService,
    private hintsService: HintsService
  ) { }

  ngOnInit() {
  }

  /**
   * 删除
   */
  _delete(){

    this.removeTableService
    .confirmRemove('ids',this.server.baseUrl + 'Service/ProductType/delProductType','token','b25dbd7138cf48e09941087e6d9a2e93')
    .then(res => {
      if(res.result_code == '0000'){
        this.delete.emit();
      }

      this.hintsService.messages(res.message,res.result_code);
      return;
    })
    .catch(err => {
      this.hintsService.messages('error','error');
      return;
    });
  }

}
